from typing import Annotated

import typer
from rich.table import Table

from apserver_mgr.shared import DEFAULT_SYSNO, init_system

app = typer.Typer()


@app.command(name="list")
def apserver_list(sysno: Annotated[str, typer.Option(help="系统代号")] = DEFAULT_SYSNO):
    """
    打印服务器清单。
    """
    console, sysinfo, servers = init_system(sysno)

    table = Table("服务器目录")

    for server in servers:
        table.add_row(server.apdirectory)
    console.print(table)
